package demo

import (
    "fmt"
    "io/ioutil"

    aepapi "gitee.com/dell_software_department/ctwing_sdk/apis/Aep_product_management"
)

func QueryProduct_Demo() {
    resp, err := aepapi.QueryProduct("dFI1lzE0EN2", "xQcjrfNLvQ", "10015488")

    if err != nil {
        fmt.Println("QueryProduct err:", err)
        return
    }
    fmt.Println("code:", resp.StatusCode, "\nerr:", err)
    bodyStr, err1 := ioutil.ReadAll(resp.Body)
    if err1 != nil {
        fmt.Println("ioutil.ReadAll err:", err1)
        return
    }
    fmt.Println(string(bodyStr))

    defer resp.Body.Close()
}
func QueryProductList_Demo() {
    resp, err := aepapi.QueryProductList("dFI1lzE0EN2", "xQcjrfNLvQ", "", "", "")

    if err != nil {
        fmt.Println("QueryProductList err:", err)
        return
    }
    fmt.Println("code:", resp.StatusCode, "\nerr:", err)
    bodyStr, err1 := ioutil.ReadAll(resp.Body)
    if err1 != nil {
        fmt.Println("ioutil.ReadAll err:", err1)
        return
    }
    fmt.Println(string(bodyStr))

    defer resp.Body.Close()
}
func DeleteProduct_Demo() {
    resp, err := aepapi.DeleteProduct("dFI1lzE0EN2", "xQcjrfNLvQ", "cd35c680b6d647068861f7fd4e79d3f5", "10015488")

    if err != nil {
        fmt.Println("DeleteProduct err:", err)
        return
    }
    fmt.Println("code:", resp.StatusCode, "\nerr:", err)
    bodyStr, err1 := ioutil.ReadAll(resp.Body)
    if err1 != nil {
        fmt.Println("ioutil.ReadAll err:", err1)
        return
    }
    fmt.Println(string(bodyStr))

    defer resp.Body.Close()
}
func CreateProduct_Demo() {
    resp, err := aepapi.CreateProduct("dFI1lzE0EN2", "xQcjrfNLvQ", "{}")

    if err != nil {
        fmt.Println("CreateProduct err:", err)
        return
    }
    fmt.Println("code:", resp.StatusCode, "\nerr:", err)
    bodyStr, err1 := ioutil.ReadAll(resp.Body)
    if err1 != nil {
        fmt.Println("ioutil.ReadAll err:", err1)
        return
    }
    fmt.Println(string(bodyStr))

    defer resp.Body.Close()
}
func UpdateProduct_Demo() {
    resp, err := aepapi.UpdateProduct("dFI1lzE0EN2", "xQcjrfNLvQ", "{}")

    if err != nil {
        fmt.Println("UpdateProduct err:", err)
        return
    }
    fmt.Println("code:", resp.StatusCode, "\nerr:", err)
    bodyStr, err1 := ioutil.ReadAll(resp.Body)
    if err1 != nil {
        fmt.Println("ioutil.ReadAll err:", err1)
        return
    }
    fmt.Println(string(bodyStr))

    defer resp.Body.Close()
}
